﻿<Window xmlns:View="clr-namespace:AutoCorrelatorGUI.View"
      x:Class="AutoCorrelatorGUI.MainWindow"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      xmlns:p="clr-namespace:AutoCorrelatorGUI.Properties"
      xmlns:util="clr-namespace:AutoCorrelatorGUI.Utility"
      xmlns:commutil="clr-namespace:Common.Utility;assembly=Common"
      xmlns:view="clr-namespace:AutoCorrelatorGUI.View"
      xmlns:commvm="clr-namespace:Common.ViewModel;assembly=Common"
      xmlns:oxy="clr-namespace:OxyPlot.Wpf;assembly=OxyPlot.Wpf"
      xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
      xmlns:command="http://www.galasoft.ch/mvvmlight"
      xmlns:ignore="http://www.ignore.com" mc:Ignorable="d ignore"
      WindowStartupLocation="Manual"
      Height="{Binding Source={x:Static p:Settings.Default}, Path=MainWindowSize.Height, Mode=TwoWay}"
      Width="{Binding Source={x:Static p:Settings.Default}, Path=MainWindowSize.Width, Mode=TwoWay}"
      Left="{Binding Source={x:Static p:Settings.Default}, Path=MainWindowSize.Left, Mode=TwoWay}"
      Top="{Binding Source={x:Static p:Settings.Default}, Path=MainWindowSize.Top, Mode=TwoWay}"
      Title="Auto Correlator"
      DataContext="{Binding Main, Source={StaticResource Locator}}">
   <Window.Resources>
      <util:RowContentConverter x:Key="rowContentConverter" />
      <commutil:ColorToBrushConverter x:Key="colorToBrushConverter" />
      <commutil:ComplimentaryBrushConverter x:Key="complimentaryBrushConverter" />
      <commvm:WellBaseComparer x:Key="WellComparer" />
   </Window.Resources>
   <Window.InputBindings>
      <KeyBinding Key="O" Modifiers="Control"
            Command="{Binding OpenFileDialogCommand, Mode=OneWay}" />
      <KeyBinding Key="R" Modifiers="Control"
            Command="{Binding LoadInputFileCommand, Mode=OneWay}" />
      <KeyBinding Key="S" Modifiers="Control"
            Command="{Binding SaveOutputDataCommand, Mode=OneWay}" />
      <KeyBinding Key="Q" Modifiers="Control" Command="{Binding ExitCommand, Mode=OneWay}" />
      <KeyBinding Key="F5" Command="{Binding RefreshPlotCommand, Mode=OneWay}" />

   </Window.InputBindings>
   <i:Interaction.Triggers>
      <i:EventTrigger EventName="Closing">
         <command:EventToCommand Command="{Binding ClosingCommand}"
               PassEventArgsToCommand="True" />
      </i:EventTrigger>
   </i:Interaction.Triggers>
   <DockPanel HorizontalAlignment="Stretch" Height="Auto" LastChildFill="True"
         Grid.RowSpan="2" VerticalAlignment="Stretch" Width="Auto">
      <Menu Grid.RowSpan="2" VerticalAlignment="Top" DockPanel.Dock="Top">
         <MenuItem Header="File">
            <MenuItem Header="Open" Command="{Binding OpenFileDialogCommand, Mode=OneWay}"
                  InputGestureText="Ctrl+O"
                  ToolTip="{x:Static p:Resources.TT_Menu_OpenFile}" />
            <Separator />
            <MenuItem Header="Process Input" InputGestureText="Ctrl+R"
                  Command="{Binding LoadInputFileCommand, Mode=OneWay}"
                  ToolTip="{x:Static p:Resources.TT_Menu_ProcessInput}" />
            <MenuItem Header="Save Plot Image"
                  Command="{Binding SaveImageCommand, Mode=OneWay}"
                  ToolTip="{x:Static p:Resources.TT_Menu_SavePlotImage}"
                  Visibility="Collapsed" />
            <MenuItem Header="Save Output Data"
                  Command="{Binding SaveOutputDataCommand, Mode=OneWay}"
                  InputGestureText="Ctrl+S"
                  ToolTip="{x:Static p:Resources.TT_Menu_ProcessInput}" />
            <Separator />
            <MenuItem Header="Exit" InputGestureText="Ctrl+Q"
                  Command="{Binding ExitCommand, Mode=OneWay}"
                  ToolTip="{x:Static p:Resources.TT_Menu_Exit}" />
         </MenuItem>
         <MenuItem Header="Stats" Visibility="Collapsed">
            <MenuItem Header="Select Stats Columns..."
                  Command="{Binding ShowStatsColumnSelectCommand, Mode=OneWay}"
                  ToolTip="{x:Static p:Resources.TT_Menu_SelectStatsColumns}" />
            <MenuItem Header="Show Stats Panel" IsCheckable="True"
                  IsChecked="{Binding StatsPanelVisible}"
                  ToolTip="{x:Static p:Resources.TT_Menu_ShowStatsPanel}" />
            <MenuItem Header="Clear Columns"
                  Command="{Binding ClearStatsPanelCommand, Mode=OneWay}"
                  ToolTip="{x:Static p:Resources.TT_Menu_ClearStatsColumns}" />
         </MenuItem>
         <MenuItem Header="View">
            <MenuItem Header="New Display Window"
                  Command="{Binding OpenNewDisplayWindowCommand, Mode=OneWay}"
                  ToolTip="{x:Static p:Resources.TT_Menu_NewDataWindow}" />
         </MenuItem>
      </Menu>
      <Grid x:Name="MainContent">
         <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition />
            <RowDefinition Height="5" />
            <RowDefinition Height="Auto" />
         </Grid.RowDefinitions>

         <View:InputFileView />
         <Grid Margin="0" Grid.Row="1">
            <Grid.ColumnDefinitions>
               <ColumnDefinition Width="150" />
               <ColumnDefinition Width="5" />
               <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <view:WellListView />
            <GridSplitter HorizontalAlignment="Stretch" Grid.Column="1" />
            <DockPanel Grid.Column="2">
               <View:OptionsView Grid.Column="2" VerticalAlignment="Top"
                     DockPanel.Dock="Top" />
               <View:DataDisplayView Grid.Column="2" Margin="0"
                     VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
                     Width="Auto" VerticalContentAlignment="Stretch" />
            </DockPanel>
         </Grid>
         <GridSplitter Grid.Row="2" VerticalContentAlignment="Stretch"
               HorizontalAlignment="Stretch" />
         <Expander x:Name="expander" Header="Stats Panel" Grid.Row="3"
               IsExpanded="{Binding StatsPanelVisible}" Visibility="Collapsed">
            <Grid>
               <DataGrid
                     commutil:DataGridColumnsBehavior.BindableColumns="{Binding StatsPanelColumnCollection}"
                     AutoGenerateColumns="False" ItemsSource="{Binding WellDataView}"
                     AlternatingRowBackground="#FFDEF9FF" CanUserDeleteRows="False"
                     CanUserReorderColumns="True" FrozenColumnCount="1" Margin="0"
                     IsReadOnly="True" ColumnWidth="Auto"
                     commutil:MultiSelect.IsEnabled="True">
                  <DataGrid.RowStyle>
                     <Style TargetType="{x:Type DataGridRow}">
                        <Style.Triggers>
                           <DataTrigger Binding="{Binding Visible}" Value="False">
                              <Setter Property="Visibility" Value="Collapsed" />
                           </DataTrigger>
                        </Style.Triggers>
                     </Style>
                  </DataGrid.RowStyle>
               </DataGrid>
            </Grid>
         </Expander>
      </Grid>
   </DockPanel>
</Window>
